package com.wy.authority.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wy.authority.entity.Post;
import com.wy.authority.service.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author 忘忧
 * @Date Created in 2021/1/12 14:48
 * @Description:
 */
@RestController
@RequestMapping("/post")
public class PostController {
    @Autowired
    private PostService postService;

   //分页
    @ResponseBody
    @GetMapping("/findall")
    public PageInfo<Post> findAll(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "6") Integer size){
        PageHelper.startPage(page,size);
        List<Post> list=postService.find();
        PageInfo<Post> pageInfo =new PageInfo<>(list);
        return pageInfo;
    }
}
